﻿@model Model.tb_document_History

@{
    ViewBag.Title = "Index";
}
<!DOCTYPE html>

<html>
<head>
    <meta name="viewport" content="width=device-width" />
    <title></title>
    <link rel="stylesheet" type="text/css" href='@Url.Content("~/Scripts/jquery-easyui/themes/default/easyui.css")'/>
    <link rel="stylesheet" type="text/css" href='@Url.Content("~/Scripts/jquery-easyui/themes/icon.css")'/>
    <link rel="stylesheet" type="text/css" href='@Url.Content("~/Scripts/jquery-easyui/demo.css")'/>
    <link rel="stylesheet" type="text/css" href='@Url.Content("~/Scripts/uploader/uploadify.css")' />
    <script type="text/javascript" src='@Url.Content("~/Scripts/jquery-1.8.2.min.js")'></script>
    <script type="text/javascript" src='@Url.Content("~/Scripts/jquery-easyui/jquery.easyui.min.js")'></script>
    <script type="text/javascript" src='@Url.Content("~/Scripts/jquery-easyui/locale/easyui-lang-zh_CN.js")'></script>
    <script type="text/javascript" src='@Url.Content("~/Scripts/uploader/jquery.uploadify.min.js")'></script>
    <script type="text/javascript" src='@Url.Content("~/Scripts/uploader/swfobject.js")'></script>
    <script type="text/javascript" src='@Url.Content("~/Scripts/jquery.unobtrusive-ajax.js")'></script>
    <script type="text/javascript" src='@Url.Content("~/Scripts/MicrosoftAjax.js")'></script>
    <script type="text/javascript" src='@Url.Content("~/Scripts/MicrosoftMvcAjax.js")'></script>

    <script type="text/javascript">
        $(document).ready(function () {
            var doctype = '@ViewBag.docType';
            $('#dgtable').datagrid({
                url: "/DocumentHistory/GetDocList?pageNumber=1&id=" + '@ViewBag.docId' + "&doctype=" + doctype,
                pagination: true,//分页控件  
                singleSelect: true,//是否单选
                rownumbers: true,
                onClickRow: dataGrid_ClickRow,
                columns: [[
                    { field: 'doc_Revo', title: '版本号', width: 100, align: 'center' },
                    { field: 'doc_Name', title: '文件名称', width: 230, align: 'center' },
                    { field: 'doc_Size', title: '大小', width: 80, align: 'center' },
                    {
                        field: 'doc_UpdateUser', title: '更新者', width: 70, align: 'center',
                        formatter: function (value, row, index) {
                            return "admin";
                        }
                    },
                    { field: 'doc_UpdateDate', title: '更新时间', width: 150, align: 'center' },
                    {
                        field: 'Edit', title: '编辑', width: 40, align: 'center',
                        formatter: function (value, row, index) {
                            return "<a href='javascript:void(0)' onclick='click_Edit(" + row.id + ")' ><img width='18px' height='18' alt='修改' src='../../Content/Images/xiugai.png' /></a>";
                        }
                    },
                    {
                        field: 'DownLoad', title: '下载', width: 40, align: 'center',
                        formatter: function (value, row, index) {
                            return "<a href='@Url.Action("GetFileFromDisk","DocumentHistory")?id=" + row.id + "'><img width='18px' height='18' alt='下载' src='../../Content/Images/xiazai.png' /></a>";
                        }
                    },
                    {
                        field: 'Delete', title: '删除', width: 40, align: 'center',
                        formatter: function (value, row, index) {
                            var linkstr = "<a href=\"javascript:void(0)\" onclick=\"click_Delete(" + row.id + ")\" ><img width='18px' height='18' alt=\"删除\" src=\"../../Content/Images/shanchu.png\" /></a>";
                            return linkstr;
                        }
                    }
                ]]
            });
            var p = $('#dgtable').datagrid('getPager');
            $(p).pagination({
                pageSize: 10,//每页显示的记录条数，默认为10  
                pageList: [8],//可以设置每页记录条数的列表  
                onSelectPage: function (pageNumber, pageSize) {
                    $('#dgtable').datagrid('options').url = "/DocumentHistory/GetDocList?pageNumber=" + pageNumber;
                    $("#dgtable").datagrid("reload");
                }
            });
            $('#dlg').dialog('close');
            $('#dlg_update').dialog('close');
            $('#doc_CreateDate').datetimebox({
                value: '@DateTime.Now.ToShortDateString()',
                required: true,
                showSeconds: false
            });
            $("#uploadify").uploadify({
                'uploader': '@Url.Content("~/Scripts/uploader/uploadify.swf")',
                'script': '@Url.Action("Import", "DocumentHistory")',
                'cancelImg': '@Url.Content("~/Scripts/uploader/cancel.png")',
                'folder': 'UpFile',
                'queueID': 'fileQueue',
                'auto': false,
                'multi': false,
                'height': 20,
                'width': 75,
                'fileSizeLimit': '10240KB',
                'fileTypeDesc': '文档类型',
                'fileTypeExts': '*.doc;*.pdf;',
                'buttonImg': '@Url.Content("~/Content/Images/daochuwenjian.png")',
            'onComplete': fun,
            'onSelect': function (e, queueId, fileObj) {
                $('#uploadify').uploadifyUpload();
            },
            'onCancel': function (file) {

            }
            });
        });

    function dataGrid_ClickRow(rowIndex, rowData) {
        $("#lbl_code").html(rowData.doc_Code);
        $("#lbl_name").html(rowData.doc_Name);
        $("#lbl_url").html(rowData.doc_URL);
        $("#lbl_status").html("有效");
        //$("#lbl_creater").html(rowData.doc_CreateUser);
        $("#lbl_creater").html("admin");
        $("#lbl_updater").html(rowData.doc_UpdateDate + "   " + rowData.doc_UpdateUser);
        $("#lbl_rev").html(rowData.doc_Revo);
        $("#lbl_keys").html(rowData.doc_KeyWord);
        if (/\.(pdf)$/.test(rowData.doc_Name)) {
            window.frames["officefrm"].location = '@Url.Action("SWFShow", "Documents")' + "?filename=" + rowData.doc_URL;
        }
        else {
            window.frames["officefrm"].location = '@Url.Action("vpoffice", "Documents")' + "?filename=" + rowData.doc_URL;
        }
        
    }

    function fun(event, queueID, fileObj, response, data) {
        if (response == "false") {
            alert("文件上传出错！");
        }
        else {
            $('#hiddenUrl').val(response);
            $('#txtName').val(fileObj.name);
            $('#txtSize').val(fileObj.size);
            alert("成功上传！");
        }
    }

    function handle(e) {
        if (e == "1") {
            $('#dgtable').datagrid('reload');
            alert("保存成功！");
            $('#dlg').dialog('close');
        } else {
            alert("保存失败！");
        }
    }
    function failed(e) {
        alert("保存失败！");
    }
    function click_Delete(_itemId) {
        if (confirm("确定要删除数据吗？")) {
            $.getJSON("/DocumentHistory/Delete_Item/" + _itemId, function (data) { alert(data); if (data == "删除成功！") { $('#dgtable').datagrid('reload'); } });
        }
    }
    function click_Edit(_itemId) {
        $('#dlg_update').window({ href: '@Url.Action("surfUpdateDoc","Documents")' + "?id=" + _itemId });
        $('#dlg_update').window('refresh');
        $('#dlg_update').window('open');
    }
    function displaytable(tableid, count) {
        for (var i = 0; i < count; i++) {
            $("#table_" + (i + 1)).hide();
        }
        $("#table_" + tableid).show();
    }
    </script>
    <style type="text/css">
        .divList {
            position: absolute;
            top: 40px;
            left: 1px;
            z-index: 99;
            width: 1048px;
        }

        a {
            text-decoration: none;
            color: #000;
        }

            a img {
                border: 0;
            }

        .biaoge {
            width: 1040px;
            font-family: '宋体';
            font-size: 12px;
            color: #10607c;
        }


            .biaoge td {
                text-align: center;
                height: 26px;
                vertical-align: middle;
                border: 1px solid #d4d3d3;
            }

        .data_tab02 {
            height: 22px;
            margin: 0px;
            padding-left: 2px;
            background: url(../../Content/Images/tab_bg02.gif) repeat-x;
        }

            .data_tab02 dd {
                width: 75px;
                height: 22px;
                line-height: 22px;
                float: left;
                text-align: center;
                cursor: pointer;
                margin-right: 2px;
            }

                .data_tab02 dd a {
                    display: block;
                    clear: both;
                    background: url(../../Content/Images/dlbeijing.png);
                    width: 100px;
                    height: 25px;
                    color: #FFFFFF;
                    font-size: 13px;
                }

                    .data_tab02 dd a:hover {
                        color: #ff9c00;
                    }

                    .data_tab02 dd a:focus {
                        color: #ff9c00;
                    }
    </style>
</head>
<body style="background-color: transparent; overflow: auto;">

    <!--编辑-->
    <div id="dlg_update" class="easyui-window" title="体系文件-编辑" data-options="iconCls:'icon-save',modal:true,closed:true,minimizable:false" style="width:700px;height:230px;">
        
    </div>
    <!--End 编辑-->

    <div style="background: #faf1e8; height: 30px; width: 100%; top: 1px; position: absolute; z-index: 99; left: 1px;">
        <table align="left" width="100%" height="27px">
            <tr>
                <td width="1029" style="font-family: '宋体'; font-size: 12px; color: #10607c;">当前位置：文件历史版本列表 </td>
            </tr>
        </table>
    </div>

    <div class="divList">
        <table cellpadding="0" cellspacing="0" width="1040px">
            <tr>
                <td>
                    <table cellpadding="0" cellspacing="0" width="1040px">
                        <tr>
                            <td width="130px" style="font-family: '宋体'; font-size: 12px; color: #10607c;">按：      
                                    <select>
                                        <option>文件名称</option>
                                    </select>
                            </td>
                            <td width="160px">
                                <input style="border: 1px solid #3496d6;" width="150px" type="text" /></td>
                            <td width="67px"><a href="#">
                                <img height="20px" src='@Url.Content("~/Content/Images/chaxun.png")' /></a></td>
                            <td align="right">
                                <a href="javascript:history.go(-1)" target="mainframe">
                                    <img src="../../Content/Images/fanhui.png" height="20px" /></a>
                            </td>
                        </tr>
                    </table>
                </td>
            </tr>
            <tr>
                <td>
                    <table cellpadding="0" cellspacing="0" class="biaoge" id="dgtable" height="400px">
                    </table>
                </td>
            </tr>
        </table>
    </div>
</body>
</html>
